﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RealtorsPortal.Data_Access_Layer;
using System.Data;
using RealtorsPortal.Entities;

namespace RealtorsPortal.AdminCP
{
    public partial class Process : System.Web.UI.Page
    {
        string cmd = ""; //command
        string param = ""; //param
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["cmd"]!=null)
            {
                cmd = Request.QueryString["cmd"].ToString();
                if (Request.QueryString["param"] != null)
                {
                    param = Request.QueryString["param"].ToString();
                    ProcessData();  
                }
                
            }
             
        }

        private void ProcessData()
        {
            AccountDAL ad = new AccountDAL();
            string json = "";
            switch (cmd)
            {
                case "getAccountByUsername":
                    
                    Account a = ad.GetAccountByUsername(param);
                    json = Utilities.ConvertToJson(a);
                    break;
                case "getTotalAccount":
                    int total = ad.GetTotalAccounts();
                    json = Utilities.ConvertToJson(total);
                    break;
                default:
                    break;
            }
            
            Response.Write(json);
            Response.End();
        }
    }
}